﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Chenxin.Lib.House.BLL
{
    public class Custom_Info
    {
        #region  成员方法

        //*******************************************
        //功能概要       ：添加客需信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：添加客需信息
        //作成者         ：姚志强
        //作成日         ：2010-03-07
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static string AddCustomInfo(Chenxin.Lib.House.Entity.Customer_BaseInfo customerBaseInfo, Chenxin.Lib.House.Entity.Customer_DemandInfo customerDemandInfo) 
        {

            //添加客源基本信息
            string customerCode = AddCustomBaseInfo(customerBaseInfo);

            //添加客源需求信息
            customerDemandInfo.CustomerCode = customerCode;
            AddCustomDemandInfo(customerDemandInfo);

            //插入系统操作日志
            string oprType = "添加客源";
            string oprContext = "添加了一条客源编号为:" + customerCode + "的记录";

            AddHouseUserLogs(customerBaseInfo, oprType, oprContext);

            return customerCode;
        }

        //*******************************************
        //功能概要       ：更新客需信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：更新客需信息
        //作成者         ：姚志强
        //作成日         ：2010-03-07
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static string UpdateCustomBaseInfo(Chenxin.Lib.House.Entity.Customer_BaseInfo customerBaseInfo, Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo)
        {
            try
            {
                //取得更新之前的客源基本信息
                Chenxin.Lib.House.Entity.Customer_BaseInfo oldCustomBaseInfo = GetCustomBaseInfo(Convert.ToString(customerBaseInfo.CustomerId));
                //取得客需信息
                List<Chenxin.Lib.House.Entity.Customer_DemandInfo> list = GetCustomerDemandInfo(Convert.ToString(customerBaseInfo.CustomerId));
               
                string strTrace;
                string updateCustomerBaseInfoContext = AddCustomBaseInfoBak(customerBaseInfo, oldCustomBaseInfo, house_TraceInfo, out strTrace);
                //有变更
                if (updateCustomerBaseInfoContext.Length > 0)
                {
                    customerBaseInfo.LastTraceDay = DateTime.Now;
                    Chenxin.Lib.House.DAL.Customer_BaseInfo.Update(customerBaseInfo);
                    updateCustomerBaseInfoContext = "客源基本信息: " + updateCustomerBaseInfoContext;
                    //写入客源跟单
                    house_TraceInfo.OprDepart = customerBaseInfo.OprDepart;
                    house_TraceInfo.OprDepartId = customerBaseInfo.OprDepartId;
                    house_TraceInfo.OprPerson = customerBaseInfo.OprPerson;
                    house_TraceInfo.OprPersonId = customerBaseInfo.OprPersonId;

                    AddTraceInfo(customerBaseInfo, strTrace, house_TraceInfo);
                    //更新客需跟单时间
                    if (list != null)
                    {
                        for (int i = 0; i < list.Count;i++ )
                        {
                            Chenxin.Lib.House.Entity.Customer_DemandInfo customerDemandInfo = list[i];
                            //名称变更
                            if (!strEqual(customerBaseInfo.CustomerName, oldCustomBaseInfo.CustomerName))
                            {
                                customerDemandInfo.CustomerName = customerBaseInfo.CustomerName;
                            }
                            customerDemandInfo.LastTraceDay = DateTime.Now;
                            Chenxin.Lib.House.DAL.Customer_DemandInfo.Update(customerDemandInfo);
                        }
                    }
                    //插入消息通知
                    string noticeTitle = "客户:" + customerBaseInfo.CustomerName + "的信息被修改";
                    AddNotice(customerBaseInfo.OprDepartId, noticeTitle, updateCustomerBaseInfoContext);
                    //插入系统操作日志
                    AddHouseUserLogs(house_TraceInfo, "更新客源", updateCustomerBaseInfoContext, oldCustomBaseInfo.CustomerId);
                }
                return "{" + string.Format("result:'true',msg:'{0}'", customerBaseInfo.CustomerCode) + "}";
            }
            catch (Exception ex)
            {
                return "{" + string.Format("result:'false',msg:'{0}'", ex.Message) + "}";
            }
        }

        //*******************************************
        //功能概要       ：更新客需信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：更新客需信息
        //作成者         ：姚志强
        //作成日         ：2010-03-07
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static string UpdateCustomDemandInfo(Chenxin.Lib.House.Entity.Customer_DemandInfo customerDemandInfo, Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo)
        {
            try
            {
                //取得更新之前的客源需求信息
                Chenxin.Lib.House.Entity.Customer_DemandInfo oldCustomDemandInfo = Chenxin.Lib.House.DAL.Customer_DemandInfo.GetModel(customerDemandInfo.DemandId);
                //取得更新之前的客源基本信息
                Chenxin.Lib.House.Entity.Customer_BaseInfo oldCustomBaseInfo =  Chenxin.Lib.House.DAL.Customer_BaseInfo.GetModel(customerDemandInfo.CustomerId);

                string updateCustomerDemandInfoContext = AddCustomDemandInfoBak(customerDemandInfo, oldCustomDemandInfo, house_TraceInfo);

                if (updateCustomerDemandInfoContext.Length > 0)
                {
                    customerDemandInfo.LastTraceDay = DateTime.Now;
                    //更新客源需求信息
                    Chenxin.Lib.House.DAL.Customer_DemandInfo.Update(customerDemandInfo);

                    updateCustomerDemandInfoContext = "客源需求信息: " + updateCustomerDemandInfoContext;

                    house_TraceInfo.OprDepart = oldCustomBaseInfo.OprDepart;
                    house_TraceInfo.OprDepartId = oldCustomBaseInfo.OprDepartId;
                    house_TraceInfo.OprPerson = oldCustomBaseInfo.OprPerson;
                    house_TraceInfo.OprPersonId = oldCustomBaseInfo.OprPersonId;
                    //写入客源跟单
                    AddTraceInfo(customerDemandInfo, updateCustomerDemandInfoContext, house_TraceInfo);

                    //更新客需跟单时间
                    if (oldCustomBaseInfo != null)
                    {
                        oldCustomBaseInfo.LastTraceDay = DateTime.Now;
                        Chenxin.Lib.House.DAL.Customer_BaseInfo.Update(oldCustomBaseInfo);
                    }

                    //插入消息通知
                    string noticeTitle = "客户:" + customerDemandInfo.CustomerName + "的信息被修改";
                    AddNotice(customerDemandInfo.OprDepartId, noticeTitle, updateCustomerDemandInfoContext);

                    //插入系统操作日志
                    string oprType = "更新客源";

                    AddHouseUserLogs(house_TraceInfo, oprType, updateCustomerDemandInfoContext, oldCustomBaseInfo.CustomerId);
                }

                return "{" + string.Format("result:'true',msg:'{0}'", customerDemandInfo.CustomerCode) + "}";

            }
            catch (Exception ex)
            {
                return "{" + string.Format("result:'false',msg:'{0}'", ex.Message) + "}";
            }
        }


        //*******************************************
        //功能概要       ：获取客源基本信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：获取客源基本信息
        //作成者         ：姚志强
        //作成日         ：2010-03-07
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static Chenxin.Lib.House.Entity.Customer_BaseInfo GetCustomBaseInfo(string customerId)
        {
            try
            {
                return Chenxin.Lib.House.DAL.Customer_BaseInfo.GetModel(new Guid(customerId));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        //*******************************************
        //功能概要       ：获取客源需求信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：获取客源需求信息
        //作成者         ：姚志强
        //作成日         ：2010-03-07
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static List<Chenxin.Lib.House.Entity.Customer_DemandInfo> GetCustomerDemandInfo(string customerId)
        {
            try
            {
                string strWhere = string.Format("CustomerId = '{0}'", customerId);

                List<Chenxin.Lib.House.Entity.Customer_DemandInfo> demandInfoList = Chenxin.Lib.House.DAL.Customer_DemandInfo.GetListArray(strWhere);

                if (demandInfoList != null && demandInfoList.Count > 0)
                {
                    return demandInfoList;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        //*******************************************
        //功能概要       ：根据需求ID获取客源需求信息
        //参数説明       ：DemandId：需求ID
        //返回值説明     ：需求信息
        //功能詳細       ：根据需求ID获取客源需求信息
        //作成者         ：何基锋
        //作成日         ：2010-06-24
        //*******************************************
        public static Chenxin.Lib.House.Entity.Customer_DemandInfo GetCustomerDemandInfoById(string DamandId)
        {
            try
            {
                string strWhere = string.Format("DemandId = '{0}'", DamandId);

                List<Chenxin.Lib.House.Entity.Customer_DemandInfo> demandInfoList = Chenxin.Lib.House.DAL.Customer_DemandInfo.GetListArray(strWhere);

                if (demandInfoList != null && demandInfoList.Count > 0)
                {
                    return demandInfoList[0];
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //*******************************************
        //功能概要       ：添加客源基本信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：添加客源基本信息
        //作成者         ：姚志强
        //作成日         ：2010-03-07
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static string AddCustomBaseInfo(Chenxin.Lib.House.Entity.Customer_BaseInfo customerBaseInfo)
        {


            //客户编号
            customerBaseInfo.CustomerCode = Chenxin.Lib.House.DAL.Customer_BaseInfo.GetCustomerCode(customerBaseInfo.OprPersonId);
            //插入对应的客源的基本信息
            Chenxin.Lib.House.DAL.Customer_BaseInfo.Add(customerBaseInfo);

            return customerBaseInfo.CustomerCode;
        }

        //*******************************************
        //功能概要       ：添加客源需求信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：添加客源需求信息
        //作成者         ：姚志强
        //作成日         ：2010-03-07
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static void AddCustomDemandInfo(Chenxin.Lib.House.Entity.Customer_DemandInfo customerDemandInfo)
        {

            //添加客源信息
            if (!Chenxin.Lib.House.DAL.Customer_DemandInfo.Exists(customerDemandInfo.CustomerId))
            {
                //插入对应的客源的基本信息
                Chenxin.Lib.House.DAL.Customer_DemandInfo.Add(customerDemandInfo);
            }
        }

        //*******************************************
        //功能概要       ：更新客源需求信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：更新客源需求信息
        //作成者         ：姚志强
        //作成日         ：2010-03-07
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static string UpdateCustomerDemand(Chenxin.Lib.House.Entity.Customer_DemandInfo customerDemandInfo)
        {
            try
            {
                //更新客源需求信息
                Chenxin.Lib.House.DAL.Customer_DemandInfo.Update(customerDemandInfo);

                return "{" + string.Format("result:'true',msg:'{0}'", "更新成功") + "}";
            }
            catch(Exception ex)
            {
                return "{" + string.Format("result:'false',msg:'{0}'", ex.Message) + "}";
            }
        }

        //*******************************************
        //功能概要       ：插入系统操作日志
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：插入系统操作日志
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：陈玉功
        //修改日         ：2010-03-25
        //*******************************************
        private static void AddHouseUserLogs(Chenxin.Lib.House.Entity.Customer_BaseInfo customerBaseInfo, string oprType, string oprContext)
        {
            //添加日志
            Chenxin.Lib.House.Entity.House_UserLogs userLogs = new Chenxin.Lib.House.Entity.House_UserLogs();

            userLogs.RecordId = Guid.NewGuid();
            userLogs.UserId = customerBaseInfo.OprPersonId;
            userLogs.UserName = customerBaseInfo.OprPerson;
            userLogs.DepartId = customerBaseInfo.OprDepartId;
            userLogs.DepartName = customerBaseInfo.OprDepart;
            userLogs.OprType = oprType;
            userLogs.OperationContext = oprContext;
            userLogs.Addtime = DateTime.Now;
            //****************修改开始***********************************
            userLogs.Id = customerBaseInfo.CustomerId;
            //****************修改结束***********************************
            Chenxin.Lib.House.BLL.House_UserLogs.AddHouseUserLogs(userLogs);
        }

        //*******************************************
        //功能概要       ：插入系统操作日志
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：插入系统操作日志
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：陈玉功
        //修改日         ：2010-03-25
        //*******************************************
        private static void AddHouseUserLogs(Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo, string oprType, string oprContext,Guid customerId)
        {
            //添加日志
            Chenxin.Lib.House.Entity.House_UserLogs userLogs = new Chenxin.Lib.House.Entity.House_UserLogs();

            userLogs.RecordId = Guid.NewGuid();
            userLogs.UserId = house_TraceInfo.TractorId;
            userLogs.UserName = house_TraceInfo.Tractor;
            userLogs.DepartId = house_TraceInfo.DepartId;
            userLogs.DepartName = house_TraceInfo.Depart;
            userLogs.OprType = oprType;
            userLogs.OperationContext = oprContext;
            userLogs.Addtime = DateTime.Now;
            //****************修改开始***********************************
            userLogs.Id = customerId;
            //****************修改结束***********************************
            Chenxin.Lib.House.BLL.House_UserLogs.AddHouseUserLogs(userLogs);
        }

        //*******************************************
        //功能概要       ：插入系统操作日志
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：插入系统操作日志
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        private static void AddHouseUserLogs(Chenxin.Lib.House.Entity.Customer_DemandInfo customerDemandInfo, string oprType, string oprContext)
        {
            //添加日志
            Chenxin.Lib.House.Entity.House_UserLogs userLogs = new Chenxin.Lib.House.Entity.House_UserLogs();

            userLogs.RecordId = Guid.NewGuid();
            userLogs.UserId = customerDemandInfo.OprPersonId;
            userLogs.UserName = customerDemandInfo.OprPerson;
            userLogs.DepartId = customerDemandInfo.OprDepartId;
            userLogs.DepartName = customerDemandInfo.OprDepart;
            userLogs.OprType = oprType;
            userLogs.OperationContext = oprContext;
            userLogs.Addtime = DateTime.Now;

            Chenxin.Lib.House.BLL.House_UserLogs.AddHouseUserLogs(userLogs);
        }

        //*******************************************
        //功能概要       ：写入客源基本信息更改记录
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：写入客源基本信息更改记录
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        private static string AddCustomBaseInfoBak(Chenxin.Lib.House.Entity.Customer_BaseInfo customerBaseInfo, Chenxin.Lib.House.Entity.Customer_BaseInfo oldCustomBaseInfo,Chenxin.Lib.House.Entity.House_TraceInfo userinfo,out string  strTrace)
        {
            StringBuilder updateContext = new StringBuilder();
            StringBuilder traceContext = new StringBuilder();
            //判断客户姓名是否被修改
            if (!strEqual(customerBaseInfo.CustomerName, oldCustomBaseInfo.CustomerName))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "CustomerName", "客户姓名", oldCustomBaseInfo.CustomerName, customerBaseInfo.CustomerName, userinfo.CompanyId, userinfo.CompanyName,0));
            }

            //判断性别是否被修改
            if (!strEqual(customerBaseInfo.Sex, oldCustomBaseInfo.Sex))
            {
                string oldSex = "";
                string newSex = "";
                if ("10".Equals(oldCustomBaseInfo.Sex))
                {
                    oldSex = "男";
                }
                else {
                    oldSex = "女";
                }
                if ("10".Equals(customerBaseInfo.Sex))
                {
                    newSex = "男";
                }
                else
                {
                    newSex = "女";
                }
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Sex", "性别", oldSex, newSex, userinfo.CompanyId, userinfo.CompanyName,0));
            }

        
            //判断国籍是否被修改
            if (!strEqual(customerBaseInfo.Nationality, oldCustomBaseInfo.Nationality))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Nationality", "国籍", oldCustomBaseInfo.Nationality, customerBaseInfo.Nationality, userinfo.CompanyId, userinfo.CompanyName,0));
            }

            //判断证件类型是否被修改
            if (!strEqual(customerBaseInfo.CertificateType, oldCustomBaseInfo.CertificateType))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "CertificateType", "证件类型", oldCustomBaseInfo.CertificateType, customerBaseInfo.CertificateType, userinfo.CompanyId, userinfo.CompanyName,0));
            }

            //判断证件号码是否被修改
            if (!strEqual(customerBaseInfo.CertificateNo, oldCustomBaseInfo.CertificateNo))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "CertificateNo", "证件号码", oldCustomBaseInfo.CertificateNo, customerBaseInfo.CertificateNo, userinfo.CompanyId, userinfo.CompanyName,0));
            }

            //判断联系地址是否被修改
            if (!strEqual(customerBaseInfo.Address, oldCustomBaseInfo.Address))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Address", "联系地址", oldCustomBaseInfo.Address, customerBaseInfo.Address, userinfo.CompanyId, userinfo.CompanyName,0));
            }
            //客户转移
            //城市
            if (!strEqual(customerBaseInfo.CityName,oldCustomBaseInfo.CityName))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "CityName", "城市", oldCustomBaseInfo.CityName, customerBaseInfo.CityName, userinfo.CompanyId, userinfo.CompanyName,0));
            }
            //公司
            if (!strEqual(customerBaseInfo.CompanyName, oldCustomBaseInfo.CompanyName))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "CompanyName", "公司", oldCustomBaseInfo.CompanyName, customerBaseInfo.CompanyName, userinfo.CompanyId, userinfo.CompanyName,0));
            }
            //部门
            if (!strEqual(customerBaseInfo.OprDepart, oldCustomBaseInfo.OprDepart))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "OprDepart", "部门", oldCustomBaseInfo.OprDepart, customerBaseInfo.OprDepart, userinfo.CompanyId, userinfo.CompanyName,0));
            }
            //人员
            if (!strEqual(customerBaseInfo.OprPerson, oldCustomBaseInfo.OprPerson))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "OprPerson", "人员", oldCustomBaseInfo.OprPerson, customerBaseInfo.OprPerson, userinfo.CompanyId, userinfo.CompanyName,0));
            }

            //公开级别是否修改
            if (!customerBaseInfo.PubLevel.Equals(oldCustomBaseInfo.PubLevel))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "PubLevel", "公开级别", convertPubLevel(oldCustomBaseInfo.PubLevel.Value), convertPubLevel(customerBaseInfo.PubLevel.Value), userinfo.CompanyId, userinfo.CompanyName,0));
            }

            traceContext.Append(updateContext.ToString());
            bool flg = false;
            //判断手机号码是否被修改
            if (!strEqual(customerBaseInfo.Mobile, oldCustomBaseInfo.Mobile))
            {
                flg = true;
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Mobile", "手机号码", oldCustomBaseInfo.Mobile, customerBaseInfo.Mobile, userinfo.CompanyId, userinfo.CompanyName,0));
            }

            //判断联系电话是否被修改
            if (!strEqual(customerBaseInfo.Phone, oldCustomBaseInfo.Phone))
            {
                flg = true;
                updateContext.Append(AddCustomerInfoBakCol(customerBaseInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Phone", "联系电话", oldCustomBaseInfo.Phone, customerBaseInfo.Phone, userinfo.CompanyId, userinfo.CompanyName,0));
            }
            if (flg)
            {
                traceContext.Append(" 联系电话改变 ");
            }
            strTrace = traceContext.ToString(); 
            return updateContext.ToString();

        }

        //*******************************************
        //功能概要       ：写入客源需求信息更改记录
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：写入客源需求信息更改记录
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        private static string AddCustomDemandInfoBak(Chenxin.Lib.House.Entity.Customer_DemandInfo customerDemandInfo, Chenxin.Lib.House.Entity.Customer_DemandInfo oldCustomDemandInfo, Chenxin.Lib.House.Entity.House_TraceInfo userinfo)
        {
            StringBuilder updateContext = new StringBuilder();

            //判断客户类型是否被修改
            if (customerDemandInfo.DemandKind != oldCustomDemandInfo.DemandKind)
            {
                string oldDemandKind = "";
                string newDemandKind = "";

                if (oldCustomDemandInfo.DemandKind == 10)
                    oldDemandKind = "求购";
                else if (oldCustomDemandInfo.DemandKind == 20)
                    oldDemandKind = "求租";

                if (customerDemandInfo.DemandKind == 10)
                    newDemandKind = "求购";
                else if (customerDemandInfo.DemandKind == 20)
                    newDemandKind = "求租";
                updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "CustomerKind", "客户类型", oldDemandKind, newDemandKind, userinfo.CompanyId, userinfo.CompanyName,100));
            }

            //判断需求类型是否被修改
            if (customerDemandInfo.DemandType != oldCustomDemandInfo.DemandType)
            {
                string oldDemandType = "";
                string newDemandType = "";

                if (oldCustomDemandInfo.DemandType == 10)
                    oldDemandType = "住房";
                else if (oldCustomDemandInfo.DemandType == 20)
                    oldDemandType = "商铺";
                else
                    oldDemandType = "办公";

                if (customerDemandInfo.DemandType == 10)
                    newDemandType = "住房";
                else if (customerDemandInfo.DemandType == 20)
                    newDemandType = "商铺";
                else
                    newDemandType = "办公";

                updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandType", "需求类型", oldDemandType, newDemandType, userinfo.CompanyId, userinfo.CompanyName,100));
            }
            if (customerDemandInfo.DemandKind == 10 && customerDemandInfo.DemandType == 10)
            {
                //判断购买时间是否被修改
                if (!strEqual(customerDemandInfo.HouseBuyTime, oldCustomDemandInfo.HouseBuyTime))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseBuyTime", "购买时间", oldCustomDemandInfo.HouseBuyTime, customerDemandInfo.HouseBuyTime, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断需求区域是否被修改
                if (!strEqual(customerDemandInfo.DemandZone, oldCustomDemandInfo.DemandZone))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandZone", "需求区域", oldCustomDemandInfo.DemandZone, customerDemandInfo.DemandZone, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断物业类型需求是否被修改
                if (!strEqual(customerDemandInfo.DemandBuilding, oldCustomDemandInfo.DemandBuilding))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandBuilding", "物业类型需求", oldCustomDemandInfo.DemandBuilding, customerDemandInfo.DemandBuilding, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断单价是否被修改
                if (!strEqual(customerDemandInfo.UnitPrice, oldCustomDemandInfo.UnitPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "UnitPrice", "单价", oldCustomDemandInfo.UnitPrice, customerDemandInfo.UnitPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断面积需求是否被修改
                if (!strEqual(customerDemandInfo.DemandArea, oldCustomDemandInfo.DemandArea))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandArea", "面积需求", oldCustomDemandInfo.DemandArea, customerDemandInfo.DemandArea, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断总价是否被修改
                if (!strEqual(customerDemandInfo.TotalPrice, oldCustomDemandInfo.TotalPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "TotalPrice", "总价", oldCustomDemandInfo.TotalPrice, customerDemandInfo.TotalPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }

                //判断购房用途是否被修改
                if (!strEqual(customerDemandInfo.HouseUse, oldCustomDemandInfo.HouseUse))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseUse", "购房用途", oldCustomDemandInfo.HouseUse, customerDemandInfo.HouseUse, userinfo.CompanyId, userinfo.CompanyName,100));
                }

                //判断考虑因素是否被修改
                if (!strEqual(customerDemandInfo.Consider, oldCustomDemandInfo.Consider))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Consider", "考虑因素", oldCustomDemandInfo.Consider, customerDemandInfo.Consider, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断服务需求是否被修改
                if (!strEqual(customerDemandInfo.ServiceDemand, oldCustomDemandInfo.ServiceDemand))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "ServiceDemand", "服务需求", oldCustomDemandInfo.ServiceDemand, customerDemandInfo.ServiceDemand, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断装修需求是否被修改
                if (!strEqual(customerDemandInfo.Fitment, oldCustomDemandInfo.Fitment))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Fitment", "装修需求", oldCustomDemandInfo.Fitment, customerDemandInfo.Fitment, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断房型需求-室是否被修改
                if (customerDemandInfo.DemandStyle_Room != oldCustomDemandInfo.DemandStyle_Room)
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandStyle_Room", "房型需求-室", Convert.ToString(oldCustomDemandInfo.DemandStyle_Room), Convert.ToString(customerDemandInfo.DemandStyle_Room), userinfo.CompanyId, userinfo.CompanyName,100));
                }

                //判断房型需求-厅是否被修改
                if (customerDemandInfo.DemandStyle_Hall != oldCustomDemandInfo.DemandStyle_Hall)
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandStyle_Hall", "房型需求-厅", Convert.ToString(oldCustomDemandInfo.DemandStyle_Hall), Convert.ToString(customerDemandInfo.DemandStyle_Hall), userinfo.CompanyId, userinfo.CompanyName,100));
                }

                //判断房型需求-卫是否被修改
                if (customerDemandInfo.DemandStyle_Toilet != oldCustomDemandInfo.DemandStyle_Toilet)
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandStyle_Toilet", "房型需求-卫", Convert.ToString(oldCustomDemandInfo.DemandStyle_Toilet), Convert.ToString(customerDemandInfo.DemandStyle_Toilet), userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断特殊需求是否被修改
                if (!strEqual(customerDemandInfo.SpecialDemand, oldCustomDemandInfo.SpecialDemand))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "SpecialDemand", "特殊需求", oldCustomDemandInfo.SpecialDemand, customerDemandInfo.SpecialDemand, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断备注是否被修改
                if (!strEqual(customerDemandInfo.Remark, oldCustomDemandInfo.Remark))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Remark", "备注", oldCustomDemandInfo.Remark, customerDemandInfo.Remark, userinfo.CompanyId, userinfo.CompanyName,100));
                }
            }
            else if (customerDemandInfo.DemandKind == 10 && customerDemandInfo.DemandType == 20)
            {
                //判断购买时间是否被修改
                if (!strEqual(customerDemandInfo.HouseBuyTime, oldCustomDemandInfo.HouseBuyTime))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseBuyTime", "购买时间", oldCustomDemandInfo.HouseBuyTime, customerDemandInfo.HouseBuyTime, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断需求区域是否被修改
                if (!strEqual(customerDemandInfo.DemandZone, oldCustomDemandInfo.DemandZone))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandZone", "需求区域", oldCustomDemandInfo.DemandZone, customerDemandInfo.DemandZone, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断物业类型需求是否被修改
                if (!strEqual(customerDemandInfo.DemandBuilding, oldCustomDemandInfo.DemandBuilding))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandBuilding", "物业类型需求", oldCustomDemandInfo.DemandBuilding, customerDemandInfo.DemandBuilding, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断单价是否被修改
                if (!strEqual(customerDemandInfo.UnitPrice, oldCustomDemandInfo.UnitPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "UnitPrice", "单价", oldCustomDemandInfo.UnitPrice, customerDemandInfo.UnitPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断面积需求是否被修改
                if (!strEqual(customerDemandInfo.DemandArea, oldCustomDemandInfo.DemandArea))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandArea", "面积需求", oldCustomDemandInfo.DemandArea, customerDemandInfo.DemandArea, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断总价是否被修改
                if (!strEqual(customerDemandInfo.TotalPrice, oldCustomDemandInfo.TotalPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "TotalPrice", "总价", oldCustomDemandInfo.TotalPrice, customerDemandInfo.TotalPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断购房用途是否被修改
                if (!strEqual(customerDemandInfo.HouseUse, oldCustomDemandInfo.HouseUse))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseUse", "购房用途", oldCustomDemandInfo.HouseUse, customerDemandInfo.HouseUse, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断考虑因素是否被修改
                if (!strEqual(customerDemandInfo.Consider, oldCustomDemandInfo.Consider))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Consider", "考虑因素", oldCustomDemandInfo.Consider, customerDemandInfo.Consider, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断期望回报率是否被修改
                if (!strEqual(customerDemandInfo.ReturnRate, oldCustomDemandInfo.ReturnRate))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "ReturnRate", "期望回报率", oldCustomDemandInfo.ReturnRate, customerDemandInfo.ReturnRate, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断备注是否被修改
                if (!strEqual(customerDemandInfo.Remark, oldCustomDemandInfo.Remark))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Remark", "备注", oldCustomDemandInfo.Remark, customerDemandInfo.Remark, userinfo.CompanyId, userinfo.CompanyName,100));
                }

            }
            else if (customerDemandInfo.DemandKind == 10 && customerDemandInfo.DemandType == 30)
            {
                //判断购买时间是否被修改
                if (!strEqual(customerDemandInfo.HouseBuyTime, oldCustomDemandInfo.HouseBuyTime))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseBuyTime", "购买时间", oldCustomDemandInfo.HouseBuyTime, customerDemandInfo.HouseBuyTime, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断需求区域是否被修改
                if (!strEqual(customerDemandInfo.DemandZone, oldCustomDemandInfo.DemandZone))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandZone", "需求区域", oldCustomDemandInfo.DemandZone, customerDemandInfo.DemandZone, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断物业类型需求是否被修改
                if (!strEqual(customerDemandInfo.DemandBuilding, oldCustomDemandInfo.DemandBuilding))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandBuilding", "物业类型需求", oldCustomDemandInfo.DemandBuilding, customerDemandInfo.DemandBuilding, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断单价是否被修改
                if (!strEqual(customerDemandInfo.UnitPrice, oldCustomDemandInfo.UnitPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "UnitPrice", "单价", oldCustomDemandInfo.UnitPrice, customerDemandInfo.UnitPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断面积需求是否被修改
                if (!strEqual(customerDemandInfo.DemandArea, oldCustomDemandInfo.DemandArea))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandArea", "面积需求", oldCustomDemandInfo.DemandArea, customerDemandInfo.DemandArea, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断总价是否被修改
                if (!strEqual(customerDemandInfo.TotalPrice, oldCustomDemandInfo.TotalPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "TotalPrice", "总价", oldCustomDemandInfo.TotalPrice, customerDemandInfo.TotalPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断考虑因素是否被修改
                if (!strEqual(customerDemandInfo.Consider, oldCustomDemandInfo.Consider))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Consider", "考虑因素", oldCustomDemandInfo.Consider, customerDemandInfo.Consider, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断期望回报率是否被修改
                if (!strEqual(customerDemandInfo.ReturnRate, oldCustomDemandInfo.ReturnRate))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "ReturnRate", "期望回报率", oldCustomDemandInfo.ReturnRate, customerDemandInfo.ReturnRate, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断备注是否被修改
                if (!strEqual(customerDemandInfo.Remark, oldCustomDemandInfo.Remark))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Remark", "备注", oldCustomDemandInfo.Remark, customerDemandInfo.Remark, userinfo.CompanyId, userinfo.CompanyName,100));
                }
            }
            else if (customerDemandInfo.DemandKind == 20 && customerDemandInfo.DemandType == 10)
            {
                //判断购买时间是否被修改
                if (!strEqual(customerDemandInfo.HouseBuyTime, oldCustomDemandInfo.HouseBuyTime))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseBuyTime", "购买时间", oldCustomDemandInfo.HouseBuyTime, customerDemandInfo.HouseBuyTime, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断需求区域是否被修改
                if (!strEqual(customerDemandInfo.DemandZone, oldCustomDemandInfo.DemandZone))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandZone", "需求区域", oldCustomDemandInfo.DemandZone, customerDemandInfo.DemandZone, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断物业类型需求是否被修改
                if (!strEqual(customerDemandInfo.DemandBuilding, oldCustomDemandInfo.DemandBuilding))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandBuilding", "物业类型需求", oldCustomDemandInfo.DemandBuilding, customerDemandInfo.DemandBuilding, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断面积需求是否被修改
                if (!strEqual(customerDemandInfo.DemandArea, oldCustomDemandInfo.DemandArea))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandArea", "面积需求", oldCustomDemandInfo.DemandArea, customerDemandInfo.DemandArea, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断购房用途是否被修改
                if (!strEqual(customerDemandInfo.HouseUse, oldCustomDemandInfo.HouseUse))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseUse", "购房用途", oldCustomDemandInfo.HouseUse, customerDemandInfo.HouseUse, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断装修需求是否被修改
                if (!strEqual(customerDemandInfo.Fitment, oldCustomDemandInfo.Fitment))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Fitment", "装修需求", oldCustomDemandInfo.Fitment, customerDemandInfo.Fitment, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断房型需求-室是否被修改
                if (customerDemandInfo.DemandStyle_Room != oldCustomDemandInfo.DemandStyle_Room)
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandStyle_Room", "房型需求-室", Convert.ToString(oldCustomDemandInfo.DemandStyle_Room), Convert.ToString(customerDemandInfo.DemandStyle_Room), userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断房型需求-厅是否被修改
                if (customerDemandInfo.DemandStyle_Hall != oldCustomDemandInfo.DemandStyle_Hall)
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandStyle_Hall", "房型需求-厅", Convert.ToString(oldCustomDemandInfo.DemandStyle_Hall), Convert.ToString(customerDemandInfo.DemandStyle_Hall), userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断房型需求-卫是否被修改
                if (customerDemandInfo.DemandStyle_Toilet != oldCustomDemandInfo.DemandStyle_Toilet)
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandStyle_Toilet", "房型需求-卫", Convert.ToString(oldCustomDemandInfo.DemandStyle_Toilet), Convert.ToString(customerDemandInfo.DemandStyle_Toilet), userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断单价是否被修改
                if (!strEqual(customerDemandInfo.UnitPrice, oldCustomDemandInfo.UnitPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "UnitPrice", "单价", oldCustomDemandInfo.UnitPrice, customerDemandInfo.UnitPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断备注是否被修改
                if (!strEqual(customerDemandInfo.Remark, oldCustomDemandInfo.Remark))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Remark", "备注", oldCustomDemandInfo.Remark, customerDemandInfo.Remark, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断特殊需求是否被修改
                if (!strEqual(customerDemandInfo.SpecialDemand, oldCustomDemandInfo.SpecialDemand))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "SpecialDemand", "特殊需求", oldCustomDemandInfo.SpecialDemand, customerDemandInfo.SpecialDemand, userinfo.CompanyId, userinfo.CompanyName,100));
                }

            }
            else if (customerDemandInfo.DemandKind == 20 && customerDemandInfo.DemandType == 20)
            {
                //判断购买时间是否被修改
                if (!strEqual(customerDemandInfo.HouseBuyTime, oldCustomDemandInfo.HouseBuyTime))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseBuyTime", "购买时间", oldCustomDemandInfo.HouseBuyTime, customerDemandInfo.HouseBuyTime, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断需求区域是否被修改
                if (!strEqual(customerDemandInfo.DemandZone, oldCustomDemandInfo.DemandZone))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandZone", "需求区域", oldCustomDemandInfo.DemandZone, customerDemandInfo.DemandZone, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断物业类型需求是否被修改
                if (!strEqual(customerDemandInfo.DemandBuilding, oldCustomDemandInfo.DemandBuilding))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandBuilding", "物业类型需求", oldCustomDemandInfo.DemandBuilding, customerDemandInfo.DemandBuilding, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断面积需求是否被修改
                if (!strEqual(customerDemandInfo.DemandArea, oldCustomDemandInfo.DemandArea))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandArea", "面积需求", oldCustomDemandInfo.DemandArea, customerDemandInfo.DemandArea, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断购房用途是否被修改
                if (!strEqual(customerDemandInfo.HouseUse, oldCustomDemandInfo.HouseUse))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseUse", "购房用途", oldCustomDemandInfo.HouseUse, customerDemandInfo.HouseUse, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断单价是否被修改
                if (!strEqual(customerDemandInfo.UnitPrice, oldCustomDemandInfo.UnitPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "UnitPrice", "单价", oldCustomDemandInfo.UnitPrice, customerDemandInfo.UnitPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断备注是否被修改
                if (!strEqual(customerDemandInfo.Remark, oldCustomDemandInfo.Remark))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Remark", "备注", oldCustomDemandInfo.Remark, customerDemandInfo.Remark, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断考虑因素是否被修改
                if (!strEqual(customerDemandInfo.Consider, oldCustomDemandInfo.Consider))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Consider", "考虑因素", oldCustomDemandInfo.Consider, customerDemandInfo.Consider, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断期望回报率是否被修改
                if (!strEqual(customerDemandInfo.ReturnRate, oldCustomDemandInfo.ReturnRate))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "ReturnRate", "期望回报率", oldCustomDemandInfo.ReturnRate, customerDemandInfo.ReturnRate, userinfo.CompanyId, userinfo.CompanyName,100));
                }
            }
            else if (customerDemandInfo.DemandKind == 20 && customerDemandInfo.DemandType == 30)
            {
                //判断购买时间是否被修改
                if (!strEqual(customerDemandInfo.HouseBuyTime, oldCustomDemandInfo.HouseBuyTime))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "HouseBuyTime", "购买时间", oldCustomDemandInfo.HouseBuyTime, customerDemandInfo.HouseBuyTime, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断需求区域是否被修改
                if (!strEqual(customerDemandInfo.DemandZone, oldCustomDemandInfo.DemandZone))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandZone", "需求区域", oldCustomDemandInfo.DemandZone, customerDemandInfo.DemandZone, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断物业类型需求是否被修改
                if (!strEqual(customerDemandInfo.DemandBuilding, oldCustomDemandInfo.DemandBuilding))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandBuilding", "物业类型需求", oldCustomDemandInfo.DemandBuilding, customerDemandInfo.DemandBuilding, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断面积需求是否被修改
                if (!strEqual(customerDemandInfo.DemandArea, oldCustomDemandInfo.DemandArea))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "DemandArea", "面积需求", oldCustomDemandInfo.DemandArea, customerDemandInfo.DemandArea, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断单价是否被修改
                if (!strEqual(customerDemandInfo.UnitPrice, oldCustomDemandInfo.UnitPrice))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "UnitPrice", "单价", oldCustomDemandInfo.UnitPrice, customerDemandInfo.UnitPrice, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断备注是否被修改
                if (!strEqual(customerDemandInfo.Remark, oldCustomDemandInfo.Remark))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Remark", "备注", oldCustomDemandInfo.Remark, customerDemandInfo.Remark, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断考虑因素是否被修改
                if (!strEqual(customerDemandInfo.Consider, oldCustomDemandInfo.Consider))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Consider", "考虑因素", oldCustomDemandInfo.Consider, customerDemandInfo.Consider, userinfo.CompanyId, userinfo.CompanyName,100));
                }
                //判断期望回报率是否被修改
                if (!strEqual(customerDemandInfo.ReturnRate, oldCustomDemandInfo.ReturnRate))
                {
                    updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "ReturnRate", "期望回报率", oldCustomDemandInfo.ReturnRate, customerDemandInfo.ReturnRate, userinfo.CompanyId, userinfo.CompanyName,100));
                }
            }
            //判断状态是否修改
            if (!customerDemandInfo.Status.Equals(oldCustomDemandInfo.Status))
            {
                string strOldStatus = string.Empty;
                string strNewStatus = string.Empty;

                strNewStatus = customerDemandInfo.Status.Value.Equals(-1) ? "无效" : "有效";
                strOldStatus = oldCustomDemandInfo.Status.Value.Equals(-1) ? "无效" : "有效";

                updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Status", "状态", strOldStatus, strNewStatus, userinfo.CompanyId, userinfo.CompanyName,100));
            }
            //判断分类是否修改
            if (!customerDemandInfo.Catalog.Equals(oldCustomDemandInfo.Catalog))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "Catalog", "类别", oldCustomDemandInfo.Catalog, customerDemandInfo.Catalog, userinfo.CompanyId, userinfo.CompanyName,100));
            }
            //公开级别是否修改
            if (!customerDemandInfo.PubLevel.Equals(oldCustomDemandInfo.PubLevel))
            {
                updateContext.Append(AddCustomerInfoBakCol(customerDemandInfo.CustomerId, userinfo.TractorId, userinfo.Tractor, "PubLevel", "公开级别", convertPubLevel(oldCustomDemandInfo.PubLevel.Value), convertPubLevel(customerDemandInfo.PubLevel.Value), userinfo.CompanyId, userinfo.CompanyName,100));
            }
            return updateContext.ToString();
        }

        private static string convertPubLevel(int PubLevel)
        {
            switch (PubLevel)
            {
                case 0:
                    return "私客户";
                    break;
                case 10:
                    return "公司级公客";
                    break;
                case 20:
                    return "跨部门级公客";
                    break;
                case 30:
                    return "部门级公客";
                    break;
                default:
                    return "私客户";
                    break;
            }
        }
        //*******************************************
        //功能概要       ：添加更该的字段信息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：添加更该的字段信息
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static string AddCustomerInfoBakCol(Guid customerId, Guid oprPersonId, string oprPerson, string colomuName, string colomuDesc, string oldValue, string newValue,Guid companyId,String companyName,int oprtype)
        {
            Chenxin.Lib.House.Entity.Customer_BaseInfo_BakCol customerBaseInfoBakCol = new Chenxin.Lib.House.Entity.Customer_BaseInfo_BakCol();
            string changeDesc = colomuDesc + "由:" + oldValue + " 修改为:" + newValue + " ";

            /*********************chenYuGong 20100331 追加开始************************/
            customerBaseInfoBakCol.CompanyId=companyId;
            customerBaseInfoBakCol.CompanyName = companyName;
            /**********************chenYuGong 20100331 追加结束*********************/
            customerBaseInfoBakCol.RecordId = Guid.NewGuid();
            customerBaseInfoBakCol.CustomerId = customerId;
            customerBaseInfoBakCol.ColumnName = colomuName;
            customerBaseInfoBakCol.ColumnDesc = colomuDesc;
            customerBaseInfoBakCol.OldValue = oldValue;
            customerBaseInfoBakCol.NewValue = newValue;
            customerBaseInfoBakCol.ChangeDesc = changeDesc;
            customerBaseInfoBakCol.OperatorId = oprPersonId;
            customerBaseInfoBakCol.Operator = oprPerson;
            customerBaseInfoBakCol.Adddate = DateTime.Now;
            customerBaseInfoBakCol.OprType = oprtype;

            Chenxin.Lib.House.DAL.Customer_BaseInfo_BakCol.Add(customerBaseInfoBakCol);

            return changeDesc;
        }

        //*******************************************
        //功能概要       ：添加客源跟单
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：添加客源跟单
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        private static void AddTraceInfo(Chenxin.Lib.House.Entity.Customer_BaseInfo customBaseInfo, string updateContext, Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo)
        {
            house_TraceInfo.TraceId = Guid.NewGuid();
            house_TraceInfo.TraceType = 0;
            house_TraceInfo.status = 1;
            house_TraceInfo.TraceContext = updateContext;
            house_TraceInfo.HouseId = customBaseInfo.CustomerId;
            house_TraceInfo.HouseCode = customBaseInfo.CustomerCode;
            house_TraceInfo.HouseAddress = customBaseInfo.CustomerName;
            house_TraceInfo.TraceTime = DateTime.Now;

            Chenxin.Lib.House.BLL.House_TraceInfo.AddHouseTraceInfo(house_TraceInfo);

        }

        //*******************************************
        //功能概要       ：添加客源跟单
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：添加客源跟单
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        private static void AddTraceInfo(Chenxin.Lib.House.Entity.Customer_DemandInfo customDemandInfo, string updateContext, Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo)
        {

            Chenxin.Lib.House.Entity.House_TraceInfo traceInfo = house_TraceInfo;

            traceInfo.TraceId = Guid.NewGuid();
            traceInfo.TraceType = 0;
            traceInfo.status = 1;
            traceInfo.TraceContext = updateContext;
            traceInfo.TractorId = customDemandInfo.OprPersonId;
            traceInfo.Tractor = customDemandInfo.OprPerson;
            traceInfo.DepartId = customDemandInfo.OprDepartId;
            traceInfo.Depart = customDemandInfo.OprDepart;
            traceInfo.HouseId = customDemandInfo.CustomerId;
            traceInfo.HouseCode = customDemandInfo.CustomerCode;
            traceInfo.HouseAddress = customDemandInfo.CustomerName;
            traceInfo.TraceTime = DateTime.Now;

            Chenxin.Lib.House.BLL.House_TraceInfo.AddHouseTraceInfo(traceInfo);

        }

        //*******************************************
        //功能概要       ：添加消息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：添加消息
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        private static void AddNotice(Chenxin.Lib.House.Entity.Customer_BaseInfo customBaseInfo, string noticeTitle, string noticeBody)
        {
            Chenxin.Lib.House.Entity.Notice notice = new Chenxin.Lib.House.Entity.Notice();

            notice.RecordId = Guid.NewGuid();
            notice.NoticeType = 0;
            /****************chenyugong 20100331 追加开始 ***********************/
            notice.CompanyId=customBaseInfo.CompanyId;
            notice.CompanyName = customBaseInfo.CompanyName;
            /****************chenyugong 20100331 追加结束***********************/
            notice.Title = noticeTitle;
            notice.body = noticeBody;
            notice.SenderId = Guid.Empty;
            notice.DelFlg = 0;
            notice.DepartMentId = customBaseInfo.OprDepartId;
            notice.SendDate = DateTime.Now;
            notice.UpdateDate = DateTime.Now;
            //notice.CityId = houseBaseInfo.CityId;
            notice.ReadFlg = 0;

            Chenxin.Lib.House.BLL.Notice.AddNotice(notice);

        }

        //*******************************************
        //功能概要       ：添加消息
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：添加消息
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        private static void AddNotice(Guid oprDepartId, string noticeTitle, string noticeBody)
        {
            Chenxin.Lib.House.Entity.Notice notice = new Chenxin.Lib.House.Entity.Notice();

            notice.RecordId = Guid.NewGuid();
            notice.NoticeType = 0;
            notice.Title = noticeTitle;
            notice.body = noticeBody;
            notice.SenderId = Guid.Empty;
            notice.DelFlg = 0;
            notice.DepartMentId = oprDepartId;
            notice.SendDate = DateTime.Now;
            notice.UpdateDate = DateTime.Now;
            //notice.CityId = houseBaseInfo.CityId;
            notice.ReadFlg = 0;

            Chenxin.Lib.House.BLL.Notice.AddNotice(notice);

        }
        
        //*******************************************
        //功能概要       ：比较字符串是否相等
        //参数説明       ：
        //返回值説明     ：
        //功能詳細       ：比较字符串是否相等
        //作成者         ：姚志强
        //作成日         ：2010-03-01
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static bool strEqual(string str1, string str2)
        {
            if (str1 == null)
            {
                str1 = "";
            }

            if (str2 == null)
            {
                str2 = "";
            }

            return str1.Equals(str2);
        }

        //*******************************************
        //功能概要       ：是否有输入公客需的权限
        //参数説明       ：
        //返回值説明     ：false：无；true：有
        //功能詳細       ：是否有输入公客需的权限
        //作成者         ：何基锋
        //作成日         ：2010-04-30
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static bool isAllowPubDemand(Guid DepartId)
        {
            bool bRet = false;

            //取得设定信息
            Chenxin.Lib.House.Entity.House_BusinessSetting entSetting = null;

            string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPART_SETTINGS, DepartId);
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            entSetting = cs.GetObject<Chenxin.Lib.House.Entity.House_BusinessSetting>(strCachKey);
            if (!cs.Hit)
            {
                entSetting = Chenxin.Lib.House.DAL.House_BusinessSetting.GetModel(DepartId);
                if (entSetting != null) cs.Set(strCachKey, entSetting, DateTime.Now.AddDays(1));
            }
            if (entSetting != null)
            {
                bRet = entSetting.AllowPubDemand;
            }
            return bRet;
        }

        //*******************************************
        //功能概要       ：获取需求客户数量上限
        //参数説明       ：DepartId：部门ID
        //返回值説明     ：需求客户数量上限
        //功能詳細       ：获取需求客户数量上限
        //作成者         ：何基锋
        //作成日         ：2010-06-23
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static int getCntOfCustomerLimit(Guid DepartId)
        {
            int iRet = 0;

            //取得设定信息
            Chenxin.Lib.House.Entity.House_BusinessSetting entSetting = null;

            string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPART_SETTINGS, DepartId);
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            entSetting = cs.GetObject<Chenxin.Lib.House.Entity.House_BusinessSetting>(strCachKey);
            if (!cs.Hit)
            {
                entSetting = Chenxin.Lib.House.DAL.House_BusinessSetting.GetModel(DepartId);
                if (entSetting != null) cs.Set(strCachKey, entSetting, DateTime.Now.AddDays(1));
            }
            if (entSetting != null)
            {
                if (entSetting.CustomerDemandNum != null)
                {
                    iRet = entSetting.CustomerDemandNum.Value;
                }
            }
            return iRet;
        }

        //*******************************************
        //功能概要       ：获取需求客户数量上限
        //参数説明       ：DepartId：部门ID
        //返回值説明     ：需求客户数量上限
        //功能詳細       ：获取需求客户数量上限
        //作成者         ：何基锋
        //作成日         ：2010-06-23
        //修改者         ：
        //修改日         ：
        //*******************************************
        public static int getDeadlineOfTrace(Guid DepartId)
        {
            int iRet = 0;

            //取得设定信息
            Chenxin.Lib.House.Entity.House_BusinessSetting entSetting = null;

            string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPART_SETTINGS, DepartId);
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            entSetting = cs.GetObject<Chenxin.Lib.House.Entity.House_BusinessSetting>(strCachKey);
            if (!cs.Hit)
            {
                entSetting = Chenxin.Lib.House.DAL.House_BusinessSetting.GetModel(DepartId);
                if (entSetting != null) cs.Set(strCachKey, entSetting, DateTime.Now.AddDays(1));
            }
            if (entSetting != null)
            {
                if (entSetting.OverTimeTraceNum != null)
                {
                    iRet = entSetting.OverTimeTraceNum.Value;
                }
            }
            return iRet;
        }

        //*******************************************
        //功能概要       ：根据当前节点类型获取客需
        //参数説明       ：dicParams-参数列表
        //返回值説明     ：客需列表
        //功能詳細       ：根据当前节点类型获取客需
        //作成者         ：何基锋
        //作成日         ：2010-08-12
        //*******************************************
        public static DataSet GetDemandListByParams(Dictionary<string, string> dicParams)
        {
            DataSet ds = null;

            int PageIndex = 1;
            int PageSize = 10;

            string OrderField = "Customer_DemandInfo.Addtime DESC";
            string TableName = "Customer_DemandInfo";
            StringBuilder strWhere = new StringBuilder();

            string FieldList = "DemandId,OprPerson,OprDepart,CustomerName,DemandKind,DemandType,DemandZone ,TotalPrice,HouseUse ,Consider,DemandArea,ServiceDemand," + 
                               "HouseBuyTime,DemandBuilding,SpecialDemand,DemandStyle_Room,DemandStyle_Hall,DemandStyle_Toilet,UnitPrice,Fitment,ReturnRate,Catalog," +
                               "Addtime,LastTraceDay,Status,DateInterval,PubLevel,HouseStyle";
            string TableFieldList = "DemandId,OprPerson,OprDepart,CustomerName,case DemandKind when '10' then '求购' else '求租' end as DemandKind," +
                                    "CASE DemandType WHEN '10' THEN '住房' WHEN '20' THEN '商铺' ELSE '办公' END AS DemandType ,DemandZone ,TotalPrice," +
                                    "HouseUse ,Consider,DemandArea,ServiceDemand,HouseBuyTime,DemandBuilding,SpecialDemand,DemandStyle_Room,DemandStyle_Hall," +
                                    "DemandStyle_Toilet,UnitPrice,Fitment,ReturnRate,Catalog,Convert(varchar(10),Addtime,120) as Addtime,LastTraceDay,Status," +
                                    "(SELECT (CASE WHEN OverTimeTraceNum=0 THEN -100 ELSE (DATEDIFF(DAY,LastTraceDay,GETDATE())- OverTimeTraceNum) END) FROM House_BusinessSetting WHERE DepartId = OprDepartId) As DateInterval," +
                                    "(Case When PubLevel=0 Then '私客' When PubLevel=10 Then '公司级共享' When PubLevel=20 Then '跨部级共享' When PubLevel=30 Then '本部级共享' Else '' End) As PubLevel," +
                                    "(CASE WHEN DemandStyle_Room IS NULL THEN '-' ELSE CAST(DemandStyle_Room AS VARCHAR(5)) END) + '/' + (CASE WHEN DemandStyle_Hall IS NULL THEN '-' ELSE CAST(DemandStyle_Hall AS VARCHAR(5)) END) + '/' + (CASE WHEN DemandStyle_Toilet IS NULL THEN '-' ELSE CAST(DemandStyle_Toilet AS VARCHAR(5)) END) AS HouseStyle";

            if (dicParams.ContainsKey("sort"))
            {
                OrderField = dicParams["sort"];
            }

            strWhere.Append(" [Status]>-1 ");

            if (dicParams.ContainsKey("PageIndex"))
            {
                PageIndex = Convert.ToInt32(dicParams["PageIndex"]);
            }
            if (dicParams.ContainsKey("PageSize"))
            {
                PageSize = Convert.ToInt32(dicParams["PageSize"]);
            }

            if (dicParams.ContainsKey("StartDate"))
            {
                strWhere.AppendFormat(" AND Addtime >= '{0}'", dicParams["StartDate"]);
            }

            if (dicParams.ContainsKey("EndDate"))
            {
                strWhere.AppendFormat(" AND Addtime <= '{0}'", dicParams["EndDate"]);
            }

            if (dicParams.ContainsKey("dtype"))
            {
                string DemandType = dicParams["dtype"];
                if (DemandType.Equals("customer_sale"))
                {
                    strWhere.AppendFormat(" AND DemandKind = {0}", 10);
                }
                else if (DemandType.Equals("customer_rent"))
                {
                    strWhere.AppendFormat(" AND DemandKind = {0}", 20);
                }
            }

            if (dicParams.ContainsKey("ParentType"))
            {
                string ParentType = dicParams["ParentType"];
                switch (ParentType)
                {
                    case "0":
                        strWhere.AppendFormat("AND CityId='{0}'", dicParams["ParentId"]);
                        break;
                    case "10":
                        strWhere.AppendFormat("AND CompanyId='{0}'", dicParams["ParentId"]);
                        break;
                    case "20":
                        strWhere.Append("AND EXISTS(");
                        strWhere.Append("       SELECT 1");
                        strWhere.Append("       FROM Chenxin_Main.dbo.Hr_Struct_DepartTreeRelation R");
                        strWhere.Append("       WHERE OprDepartId = R.ChildId");
                        strWhere.AppendFormat(" AND ParentId='{0}'", dicParams["ParentId"]);
                        strWhere.Append("   )");
                        break;
                    case "25":
                    case "30":
                        strWhere.AppendFormat("AND OprDepartId='{0}'", dicParams["ParentId"]);
                        break;
                    case "40":
                        strWhere.AppendFormat("AND OprPersonId='{0}'", dicParams["ParentId"]);
                        break;
                    default:
                        break;
                }
            }

            ds = Chenxin.Lib.House.DAL.Customer_DemandInfo.GetList(PageIndex, PageSize, OrderField, TableName, strWhere.ToString(), FieldList, TableFieldList, true);
            return ds;
        }
        #endregion 成员方法
    }
}
